﻿<template>
  <span v-loading="isLoading">{{ name?name:id}}</span>
</template>
<script>
function noop() {
}

export default {
  name: "CompanyName",
  props: {
    //选中值
    value: {},
  },
  model: {
    prop: 'value',
    event: 'change'
  },
  data() {
    return {
      name:'',
      isLoading: true,
    }
  },
  computed: {
    id: {
      get() {
        return this.value;
      },
      set(value) {
        this.$emit("change", value);
      }
    }
  },
  watch: {
    value() {
      this.loadOfficeData();
    },
    parent() {
      this.loadOfficeData();
    },
  },
  mounted() {
    this.loadOfficeData();
  },
  methods: {

    //组织机构
    loadOfficeData: function () {
      this.$get("/company/get/"+this.value, {}, (response) => {

        if (!response.data) {
          return;
        }
        this.name = response.data.name;

      }, () => {
        this.isLoading = false;
      })
    },
  }
};
</script>
